package com.zhentao.controller;

import com.zhentao.pojo.Role;
import com.zhentao.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/role")
public class RoleController {

    //注入服务
    @Autowired
    private RoleService roleService;

    //测试调用新增方法
    @GetMapping("/add")
    public String testAdd(){
        try {
            Role role = new Role();
            role.setName("张三");
            role.setAge(18);
            roleService.add(role);
            return "ok";
        } catch (Exception e) {
           // throw new RuntimeException(e);
            return "error";
        }
    }
}
